package com.example.jianzhioffer;

/**
 * Created by Quincy on 2018/10/7.
 * 圆圈中最后剩下的数
 */
public class LastRemaining_Solution {

    public int LastRemaining_Solution(int n, int m) {
        if(n==0) return -1;

        int s=0;
        for(int i=2;i<=n;i++){
            s=(s+m)%i;
        }
        return s;
    }
}
